/*******************************************************************************
 * Copyright (C) 2021 the Eclipse BaSyx Authors
 * 
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 * 
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 * 
 * SPDX-License-Identifier: MIT
 ******************************************************************************/
package org.eclipse.basyx.examples.contexts;

import org.eclipse.basyx.components.aas.servlet.AASAggregatorServlet;
import org.eclipse.basyx.components.registry.servlet.InMemoryRegistryServlet;
import org.eclipse.basyx.vab.protocol.http.server.BaSyxContext;

/**
 * BaSyx context that contains an Industrie 4.0 Servlet infrastructure <br>
 * - One in-memory AAS Server that receives and hosts asset administration
 * shells and submodels<br>
 * - One in-memory registry that manages AAS and sub model registrations<br>
 * 
 * @author kuhn, schnicke
 *
 */
public class BaSyxExamplesContext extends BaSyxContext {

	/**
	 * Version of serialized instance
	 */
	private static final long serialVersionUID = 1L;

	private static final String CONTEXT = "/basys.examples";

	private static final String AASSERVERFRAGMENT = "/Components/AasServer/";
	public static final String AASSERVERURL = CONTEXT + AASSERVERFRAGMENT;

	private static final String REGISTRYFRAGMENT = "/Components/Registry/";
	public static final String REGISTRYURL = CONTEXT + REGISTRYFRAGMENT;

	/**
	 * Constructor
	 */
	public BaSyxExamplesContext() {
		// Invoke base constructor to set up Tomcat server in basys.components context
		super(CONTEXT, "");

		// Define Servlet infrastucture
		addServletMapping(REGISTRYFRAGMENT + "*", new InMemoryRegistryServlet());
		addServletMapping(AASSERVERFRAGMENT + "*", new AASAggregatorServlet());
	}
}
